Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly escape quotes in passwords by calling to_python #361

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Oct 16, 2024

database passwords can contain special characters, especially " and '
so we can't just print the value of the field enclosed by single quotes
as that would break whenever the user uses a literal ' in their password

database passwords can contain special characters, especially " and '
so we can't just print the value of the field enclosed by single quotes
as that would break whenever the user uses a literal ' in their password
@evgeni evgeni added Bug Something isn't working and removed Not yet reviewed labels Oct 16, 2024
@@ -24,7 +24,7 @@ DATABASES = {
'ENGINE': 'django.db.backends.postgresql',
'NAME': '<%= scope['pulpcore::postgresql_db_name'] %>',
'USER': '<%= scope['pulpcore::postgresql_db_user'] %>',
'PASSWORD': '<%= scope['pulpcore::postgresql_db_password'] %>',
'PASSWORD': <%= scope.call_function('to_python', [scope['pulpcore::postgresql_db_password']]) %>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that the function from stdlib? Then maybe use the new namespaced version?

Suggested change
'PASSWORD': <%= scope.call_function('to_python', [scope['pulpcore::postgresql_db_password']]) %>,
'PASSWORD': <%= scope.call_function('stdlib::to_python', [scope['pulpcore::postgresql_db_password']]) %>,

Copy link
Member Author

@evgeni evgeni Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is, the rest of the file is not using the namespaced version, so I didn't want to diverge

@ekohl ekohl merged commit 8103e5c into master Oct 16, 2024
23 checks passed
@ekohl ekohl deleted the escape-passwords branch October 16, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants